<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><{:C('web_site_name')}>---新闻添加</title>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/common.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/main.css"/>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/lib.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/layer.min.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/fileuploader.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/kindeditor/kindeditor-all-min.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/kindeditor/lang/zh_CN.js"></script>
</head>
<body>


<form  id="info_form" >
<input type="hidden" value="<?php echo isset($pid)?$pid:0 ;?>" name="info[pid]">
<div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i>首页<span class="crumb-step">&gt;</span><span class="crumb-name">新闻咨询添加</span></div>
        </div>
        
        <div class="result-wrap">
            <div class="result-content">
                    <table class="insert-tab" width="100%">
                        <tbody>
                            <tr>
                                <th><i class="require-red">*</i>选择栏目：</th>
                                <td>
                               	<select name="info[typeid]"  id="typeid" >
       	<?php 
       
  			if(isset($category) && $category){
  				foreach($category as $c_key => $c_v){	
  			
  		?>
  		<option value="<?php echo $c_v['id'] ;?>" ><?php echo $c_v['html'];?><?php echo $c_v['typename']  ; ?></option>
  		<?php 
  			}
  		}	
  		?>
       	</select>
           
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>名称：</th>
                                <td>
                                <input id="title" name="info[title]" type="text" value="" class="common-text required" />
           
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red"></i>新闻图片：</th>
                                <td>
                                <input type="text" name="info[image]" id="image" readonly><a id="upload_pic" href="javascript:void(0)" class="btn btn-primary btn2">上传图片</a>
           					
                                </td>
                            </tr> 
                            <tr>
                                <th><i class="require-red"></i>图片预览：</th>
                                <td>
                                <img id="preview" src="" style="display:none">
           					
                                </td>
                            </tr> 
                             <tr>
                                <th><i class="require-red"></i>pc图片：</th>
                                <td>
                                <input type="text" name="info[pc_image]" id="pc_image" readonly><a id="upload_pc_pic" href="javascript:void(0)" class="btn btn-primary btn2">上传图片</a>
                            
                                </td>
                            </tr> 
                            <tr>
                                <th><i class="require-red"></i>图片预览：</th>
                                <td>
                                <img id="pc_preview" src="" style="display:none">
                            
                                </td>
                            </tr> 
                            <tr>
                                <th><i class="require-red"></i>wap图片：</th>
                                <td>
                                <input type="text" name="info[wap_image]" id="wap_image"  readonly><a id="upload_wap_pic" href="javascript:void(0)" class="btn btn-primary btn2">上传图片</a>
                            
                                </td>
                            </tr> 
                            <tr>
                                <th><i class="require-red"></i>图片预览：</th>
                                <td>
                                <img id="wap_preview" src="" style="display:none">
                            
                                </td>
                            </tr> 
                            <tr>
                                <th>关键词：</th>
                                <td>
                                <input id="title" name="info[keysword]" type="text" value="" class="common-text required" />
           
                                </td>
                            </tr>
                            <tr>
                                <th>权重：</th>
                                <td>
                                <input id="weight" name="info[weight]" type="text" value="0" class="common-text required" />
           
                                </td>
                            </tr>
                            <tr> 
                                <th>点击数量：</th>
                                <td>
                                <input id="click" name="info[click]" type="text" value="" class="common-text required" />
           
                                </td>
                            </tr>
                           <tr> 
                                <th>跳转地址第三方：</th>
                                <td>
                                <input id="jump_url" name="info[jump_url]" type="text" value="" class="common-text required" />
           
                                </td>
                            </tr>  
                            <tr>
                                <th>属性：</th>
                                <td>
                                <?php 
				
					foreach(C('content_att') as $attr_key => $attr_val){
						echo "<input type='checkbox' name='flag[]' value='{$attr_key}'>".$attr_val."&nbsp;&nbsp;" ;
					}
				
			?>
           
                                </td>
                            </tr>
                             <tr> 
                                <th>添加日期：</th>
                                <td>
                                <input name='info[create_date]' onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<?php echo date("Y-m-d H:i:s" , time());?>" id="create_date" type="text" readonly class="common-text required" />
           
                                </td>
                            </tr>
                          <tr> 
                                <th>内容：</th>
                                <td>
 								<textarea class="common-text required"  id="content" name="info[content]"></textarea>           
                                </td>
                            </tr>
                           <tr> 
                                <th>介绍	：</th>
                                <td>
                                <textarea class="common-text required"  name="info[introduce]"></textarea>
                                </td>
                            </tr> 
                        
                            <tr>
                                <th>状态：</th>
                                <td>
                                <input type="radio" name="info[status]" value="1" checked/> 启用
   								 <input type="radio" name="info[status]" value="0"/> 禁用
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" id="btn" value="提交" type="button">
                                </td>
                            </tr>
                        </tbody></table>
            </div>
        </div>
       
      </form>  
    
   </body>
   </html>    
   
<script>
KindEditor.ready(function(K) {
    window.editor = K.create('#content',{
				width:'90%',
				height:'400px',
				allowFileManager:false ,
				allowUpload:false,
				afterCreate : function() {
					this.sync();
				},
				afterBlur:function(){
				      this.sync();
				},
				//extraFileUploadParams:{
					//'cookie':'<?php echo $_COOKIE['admin_auth'];?>'
			//	},
				uploadJson:"<?php echo U("news/index");?>&action=upload&session=<?php echo session_id();?>"
						
    });
});
var loadding_0 ;
$(function(){
	$("#btn").bind("click" , function(){
		if($.trim($("#title").val()) == '' ){
			layer.msg("名称不可以为空");
			return false ;
		}
		var data_ = $("#info_form").serializeArray() ;
		$.ajax({
			type: "POST",
			url: "<?php echo  U("news/add" , array('action'=>'doadd' , 'inajax'=>1 ) ) ; ?>" ,
			data: data_,
			cache:false,
			dataType:"json",
			async:true,
			success: function(msg){
				var shtml = '' ;
				var list = msg.resultinfo.list;
				if(msg.resultcode != 1 ){
					layer.msg(msg.resultinfo.errmsg);
					return false ;
				}else{
					parent.common_request();
					parent.close_add_div();
				}
				layer.close(loadding_0);
			},
			beforeSend:function(){
				 loadding_0 = layer.load('数据正在加载中。。。。。。'); 
			},
			error:function(){
				layer.msg('服务器繁忙请稍后');
				return false ;
			}
			});
		
	});
	 var img_uploader = new qq.FileUploaderBasic({
	        allowedExtensions: ['jpg','gif','jpeg','png'],
	        button: document.getElementById("upload_pic"),
	        multiple: false,
	        action: "<?php echo U('news/index' , array('action'=>'upload_pic') )?>",
	        inputName: 'file',
	        forceMultipart: true, //用$_FILES
	        messages: {
	            typeError: "图片类型出错",
	            //sizeError: "七个上传小图",
	            //minSizeError: lang.upload_minsize_error,
	            //emptyError: lang.upload_empty_error,
	            noFilesError: "没有文件上传"
	            //onLeave: lang.upload_onLeave
	        },
	        showMessage: function(message){
	           alert(message);
	        },
	        onSubmit: function(id, fileName){
	        	loadding_0 = layer.load('图片正在上传中，请稍等。。。。'); 
	        },
	        onComplete: function(id, fileName, result){
	        	
				if(result['resultcode']){
					$("#image").val(result['resultinfo']['list']['pic']);
					$("#preview").attr("src" , "<?php echo C('upload_domain')?>/News/"+result['resultinfo']['list']['pic']).show();
				}else{
					layer.msg(result['message']);
				}
	            layer.close(loadding_0);
	        }
	    });	
     var pc_img_uploader = new qq.FileUploaderBasic({
            allowedExtensions: ['jpg','gif','jpeg','png'],
            button: document.getElementById("upload_pc_pic"),
            multiple: false,
            action: "<?php echo U('news/index' , array('action'=>'upload_pic') )?>",
            inputName: 'file_pc',
            forceMultipart: true, //用$_FILES
            messages: {
                typeError: "图片类型出错",
                //sizeError: "七个上传小图",
                //minSizeError: lang.upload_minsize_error,
                //emptyError: lang.upload_empty_error,
                noFilesError: "没有文件上传"
                //onLeave: lang.upload_onLeave
            },
            showMessage: function(message){
               alert(message);
            },
            onSubmit: function(id, fileName){
                loadding_0 = layer.load('图片正在上传中，请稍等。。。。'); 
            },
            onComplete: function(id, fileName, result){
                
                if(result['resultcode']){
                    $("#pc_image").val(result['resultinfo']['list']['pic']);
                    $("#pc_preview").attr("src" , "<?php echo C('upload_domain')?>/News/"+result['resultinfo']['list']['pic']).show();
                }else{
                    layer.msg(result['message']);
                }
                layer.close(loadding_0);
            }
        }); 
     var wap_img_uploader = new qq.FileUploaderBasic({
            allowedExtensions: ['jpg','gif','jpeg','png'],
            button: document.getElementById("upload_wap_pic"),
            multiple: false,
            action: "<?php echo U('news/index' , array('action'=>'upload_pic') )?>",
            inputName: 'file_wap',
            forceMultipart: true, //用$_FILES
            messages: {
                typeError: "图片类型出错",
                //sizeError: "七个上传小图",
                //minSizeError: lang.upload_minsize_error,
                //emptyError: lang.upload_empty_error,
                noFilesError: "没有文件上传"
                //onLeave: lang.upload_onLeave
            },
            showMessage: function(message){
               alert(message);
            },
            onSubmit: function(id, fileName){
                loadding_0 = layer.load('图片正在上传中，请稍等。。。。'); 
            },
            onComplete: function(id, fileName, result){
                
                if(result['resultcode']){
                    $("#wap_image").val(result['resultinfo']['list']['pic']);
                    $("#wap_preview").attr("src" , "<?php echo C('upload_domain')?>/News/"+result['resultinfo']['list']['pic']).show();
                }else{
                    layer.msg(result['message']);
                }
                layer.close(loadding_0);
            }
        });         	 
}) ; 


</script>
        
        